using System;
using Microsoft.SPOT;

namespace CobraController
{
  public delegate void NewMessageEventHandler(object sender, MessageEventArgs se);

  public class MessageEventArgs : EventArgs
  {
    private string _latestMessage;

    public MessageEventArgs(string latestMessage)
    {
      _latestMessage = latestMessage;
    }

    public string LatestMessage
    {
      get { return _latestMessage; }
    }
  }

  class MessageEventHandler
  {
    public static event NewMessageEventHandler MessageEvent;

    public static void onMessageEvent(string msg)
    {
      if (MessageEvent != null)
      {
        var scea = new MessageEventArgs(msg);
        MessageEvent(MessageEvent, scea);
      }
    }
  }
}
